#ifndef TEXTQUERY_H
#define TEXTQUERY_H
#define DEBUG 0
#include "Sentence.h"
#include<iostream>
using std::cout;using std::endl;
#include<vector>
using std::vector;
#include<fstream>
using std::ifstream;using std::ofstream;
#include<sstream>
using std::istringstream;
#include<string>
using std::string;
#include<map>
#include<set>
#include<memory>
using std::shared_ptr; using std::make_shared;
#include<algorithm>
using std::find_if;


class Query_base;
class QueryResult;
class TextQuery{
    friend QueryResult;
    friend Query_base;
    public:
        TextQuery() = default;
        TextQuery(const string &filePath);  //按文本文件路径构造
		QueryResult query(const string &inq) const;      //查询单词
        void showText();                    //展示文本内容
        ~TextQuery(){}
    protected:
        Sentence sent; //内置的句子类
    private:
        shared_ptr<vector<Sentence>> file;    //vector按句子存储文本
        std::map<string,std::set<int>> whichSent;   //保存单词及其出现的句子序号
        void extractWord(const string &,int);     //从句子中提取单词给map
        bool checkSent(const string &);     //单词是否为句子
};

#endif